<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" th:href="@{/css/font.css}">
    <link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <script th:src="@{/webjars/jquery/3.5.1/jquery.min.js}"></script>
    <script th:src="@{/js/ions_alert.js}"></script>
    <script th:src="@{/common/common.js}"></script>
    <script th:src="@{/js/sweetalert.min.js}"></script>
    <link rel="stylesheet" th:href="@{/css/sweetalert.css}">
</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="#">首页</a>
        <a href="#">演示</a>
        <a>
          <cite>导航元素</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <dd class="layui-form layui-col-md12 x-so">
            <button class="layui-btn" lay-submit="" lay-filter="search" id="search"><i class="layui-icon" >&#xe615;</i></button>
        </dd>
    </div>
    <table class="layui-table middle">
        <thead>
        <tr>
            <th>用户名</th>
            <th>商品详情</th>
        </tr>
        </thead>
        <tbody id="tbody" class="billList">
        </tbody>
    </table>
    <div class="page" id="page">
        <div>
            <a class="prev" href="javaScript:" id="begin" onclick="appointmentPageGo('begin')"><&lt;</a>
            <a class="prev" href="javaScript:" onclick="appointmentPageGo('forward')">&lt;</a>
            <button type="button" class="layui-btn layui-btn-fluid" id="currentPage">1</button>
            <a class="next" href="javaScript:" onclick="appointmentPageGo('nextPage')">&gt;</a>
            <a class="next" href="javaScript:" onclick="appointmentPageGo('end')">&gt;&gt;</a>
        </div>
    </div>
    <div>
        <span class="x-right" style="line-height:40px">共<span id="bigPage">0</span>页</span>&nbsp;&nbsp;&nbsp;
        <span class="x-right" style="line-height:40px">共<span id="many">0</span>条数据</span>&nbsp;&nbsp;&nbsp;

    </div>

</div>
<script>
    $(function () {

        let currentPage = $("#currentPage").text();
        let bigPage = $("#bigPage").text();
        $("#search").click(function () {
            findAppointmentList(currentPage,'search',bigPage);
        })
    });
    function appointmentPageGo(param){
        let currentPage = $("#currentPage").text();
        let bigPage = $("#bigPage").text();

        findAppointmentList(currentPage,param,bigPage);
    }
    //查找 预约记录
    function findAppointmentList(currentPage,param,bigPage) {
        $.ajax({
            url: "/admin/findAppointmentList",
            type: "GET",
            data:　{
                currentPage: currentPage,
                param:param,
                bigPage:bigPage
            },
            success:function (resultInfo) {

                console.log(resultInfo);
                console.log(resultInfo.data.list[0]);
                console.log(resultInfo.data.list[1]);



                if(resultInfo.flag) {
                    var text = '';
                    for (let i = 0; i < resultInfo.data.list.length / 2; i++) {
                        text += '<tr>\n' +
                            '                <td>' +
                            '                    <a style="color:#90dbdb;" href="#" onclick="x_admin_show(\'用户详情\',\'/admin/bill/showUserMessage?username=' + resultInfo.data.list[i*2+1].username + '\',600,500)">' + resultInfo.data.list[i*2+1].username + '</a>\n' +
                            '                </td>\n' +
                            '                <td>\n' +
                            '                    <a style="color:#db6508;" href="#" onclick="x_admin_show(\'商品详情\',\'/admin/appointment/showWaresMessage?no=' + resultInfo.data.list[i*2].no + '\',600,500)">' + resultInfo.data.list[i*2].name + '</a>\n' +
                            '                </td>\n' +
                            '            </tr>';
                        text += '';
                        $(".billList").html(text);
                        $("#currentPage").html(resultInfo.data.currentPage);
                        $("#many").html(resultInfo.data.totalCount);
                        $("#bigPage").text(resultInfo.data.totalPage);
                    }
                }
                else{
                        alert(resultInfo.message);
                    }

            }
        })
    }

</script>
</body>
</html>